GT.abilityInit.obj({
    {
        ak = abilityId['升级'],
        ability_end = {
            {
                text = '升级',
                call = function(a, u, tu, td, ti, tp)
                    if u['建筑等级'] ~= nil then
                        local lv = (u['建筑等级']) + 1
                        local p = u:get_player()
                        local u_build = u:diy_get_build_lv_up()
                        local lv_data = u_build[lv]
                        if lv <= #u_build then
                            u:set('建筑等级', lv, nil)
                            lv_data.lvup_fun(u, lv_data, unitInit[u:get_UnitKey()])
                            p:set_role_res(Game.res_type['金币'], p:get_role_res(Game.res_type['金币']) -
                                lv_data.gold)
                            if lv_data.pop ~= nil then
                                p:set_role_res(Game.res_type['金币'], p:get_role_res(Game.res_type['人口']) -
                                    lv_data.pop)
                            end

                            GT.sfx.create_sfx_on_unit({
                                sfx_id = 102582,
                                socket = 'origin',
                                unit = u
                            })
                        end
                        if #u_build == lv then
                            u:api_remove_abilities_in_type(AbilityCategory['普通技能'], a:get_AbilityKey())
                            uiGame_A['升级'].u[p.pid].binding.show = false
                            uiGame_A['升级'].u[p.pid].binding.skill = nil
                        end
                    end
                end
            }
        },
    },
    {
        ak = abilityId['出售'],
        ability_end = {
            {
                text = '按造价50%出售',
                call = function(a, u, tu, td, ti, tp)
                    if u:get_type() == UnitCategory['建筑'] then
                        local p = u:get_player()

                        GT.sfx.create_sfx_on_point({
                            sfx_id = 103764,
                            point = u:api_get_position(),
                            height = 10
                        })

                        GT.music.play_sound({
                            role = p,
                            sid = 134230682,
                        })

                        local u_build = u:diy_get_build_lv_up()
                        local build_skill = u['绑定建造技能']
                        --当前建筑等级
                        local lv = u['建筑等级']
                        ---获得建筑初始消耗金币消耗
                        local gold = abilityInit[build_skill].playerKv[Game.res_type['金币']]
                        local pop = abilityInit[build_skill].playerKv[Game.res_type['人口']]
                        for i = 1, lv, 1 do
                            gold = u_build[i].gold + gold
                        end
                        for i = 1, lv, 1 do
                            pop = u_build[i].pop + pop
                        end
                        gold = gold / 2
                        p:set_role_res(Game.res_type['金币'], p:get_role_res(Game.res_type['金币']) + gold)
                        p:set_role_res(Game.res_type['人口'], p:get_role_res(Game.res_type['人口']) + pop)
                        u:api_delete()
                        uiGame_A['出售'].u[p.pid].binding.show = false
                        uiGame_A['出售'].u[p.pid].binding.skill = nil
                        uiGame_A['升级'].u[p.pid].binding.show = false
                        uiGame_A['升级'].u[p.pid].binding.skill = nil
                        unitInit_Create_fun[u:api_get_id()] = nil
                    end
                end
            }
        }


    }
})
